$(function() {
    $('#Commonbottom').load('../assets/public/html/PublicBottom.html')
    var offId = window.location.search,
        parts = offId.split("="),
        last_part = parts[1];
    //显示接口start
    console.log(last_part);
    var positionDetail = Interceptor('/details', 'post', {
        'officialId': last_part,

    });

    if (positionDetail.data[0][0] == undefined) {
        $('.cuowu').css('display', 'block');
        $('.posi_back').css('margin-bottom', '30px')
        $('.positionBox_right').css('display', 'none');
        $('.positionBox_left').css('display', 'none');
        $('.none').hide();
        $('.personnelMatters').hide();
    }
    //投档接口
    var throwNow = positionDetail.data[1].examStatus;
    if (throwNow == 1) {
        $('.summitTime').text('已投档');
        $('.summitTime').removeAttr('href'); //去掉a标签中的href属性 
        $('.summitTime').removeAttr('onclick');
        $('.toud').css("cursor", "default");
        $('.toud').click(function() {
            Interceptor('/throwNow', 'post', {
                'officialId': last_part
            });
            $('.summitTime').text('已投档');

        });
    } else {
        $('.summitTime').text('立即投档');
    }



    var colle = positionDetail.data[2].collStatus;
    if (colle == 1) {
        $('.Colle').text("已收藏");
        $('.Colle').hover(function() {
                $('.Colle').text("取消收藏");
            },
            function() {
                $('.Colle').text("已收藏");
            });
    } else {
        $('.Colle').text("收藏");
    }
    $('.enshrine').click(function() {
        if (colle == 0) {
            Interceptor('/cancel', 'post', {
                'officialId': last_part
            });
            $('.Colle').text("收藏");
            colle = 1;
            window.location.reload();
        }
        if (colle == 1) {
            Interceptor('/collection', 'post', {
                'officialId': last_part
            });
            $('.Colle').text("已收藏");
            colle = 0;
            window, location.reload();
        }

    });
    const positionBoxLeft = `
    <div class="position_name">
    <span class="posi_name">${positionDetail.data[0][0].official}</span>
    <div class="region"><img src="https://19jwshow.oss-cn-shenzhen.aliyuncs.com/recruit/icon/icon_dw.png" alt="">
        <span class="ardress">${positionDetail.data[0][0].company_area}</span>
    </div>
        <p class="price">${positionDetail.data[0][0].job_money}薪</p>
    </div>
    <div class="requirement">
        <span>本科以上</span>
        <span>${positionDetail.data[0][0].wordweek}天/周</span>
        <span>5年以上</span>
    </div>
    <div class="treatment">
        <span>${positionDetail.data[0][0].company_welfare}</span>
         </div>
    `
    $('.positionBox_left').append(positionBoxLeft);
    const positionDe = `
    <img src="${positionDetail.data[0][0].header}" alt="" class="matters_img">
            <div class="matters_indu">
            <div class="matter_one">
                <p class="matter_name">${positionDetail.data[0][0].username}</p>
                <span class="matter_renshi">人事</span>
            </div>
            <p class="matter_position">人事总监</p>
            </div>
    `
    $('.userName').append(positionDe);
    $('#Commonbottom').load('../assets/public/html/PublicBottom.html');
    const sizebox = `
    <p class="sizebox">${positionDetail.data[0][0].management}</p>
    `
    $('.one').append(sizebox);
    const master = `
    <p class="size">${positionDetail.data[0][0].username}</p>
    `
    $('.master').append(master);

    function formatDateTime(inputTime) {
        var date = new Date(inputTime * 1000);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        return y + '年' + m + '月' + d + '日';
    };
    var time = positionDetail.data[0][0].company_addtime;
    var date = formatDateTime(time);
    const timeStart = `
    <p class="size">${date}</p>
    `
    $('.timeStart').append(timeStart);

    const comNameFont = `
    <p class="size">${positionDetail.data[0][0].company_name}</p>
    `
    $('.nameFont').append(comNameFont);

    const comAddmoney = `
    <p class="size">${positionDetail.data[0][0].add_money}</p>
    `
    $('.addMoney').append(comAddmoney);
    const comtype = `
    <p class="size">${positionDetail.data[0][0].type}</p>
    `
    $('.comtype').append(comtype);
    const comaddress = `
    <p>${positionDetail.data[0][0].company_area}</p>
    `
    $('.bus_ti_content').append(comaddress);
    const comIntroduce = `
    <div class="companyIntitle">
        <img src="${positionDetail.data[0][0].company_logo}" alt="" class="comLogo">
        <div class="comIntiRight">
            <p class="comname">${positionDetail.data[0][0].company_name}</p>
            <span class="type">${positionDetail.data[0][0].type}</span>
            <img src="https://19jwshow.oss-cn-shenzhen.aliyuncs.com/recruit/icon/grepPeople.png" alt="">
            <p class="NumberOfPeople">${positionDetail.data[0][0].com_official}人以上</p>
        </div>
    </div>
    <div class="companyIncontent">${positionDetail.data[0][0].company_introduction}</div>
    `
    $('.CompanyIntroduction').append(comIntroduce);
    const requirements = `
    <li class="jreq_content">${positionDetail.data[0][0].requirement}</li>
    `
    $('.requirements').append(requirements);
    const official_describe = `
    <li class="jreq_content">${positionDetail.data[0][0].official_describe}</li>
    `
    $('.official_describe').append(official_describe);
    //显示接口end

})